/*
 * main.cpp
 *
 *  Created on: 2008-12-1
 *      Author: Administrator
 */

#include <iostream>
#include <stdlib.h>
using namespace std;

class String
{
    private:
        int length;
        char * t_string;
    public:
        String(const char * s);
        ~String();
        String & ReplaceChar(char s, const char t);
        void PrintString();
};
String::String(const char * s)
{
    length = strlen(s);
    t_string = new char [length + 1];
    strcpy(t_string, s);
}

String::~String()
{
    delete [] t_string;
}

String & String::ReplaceChar(char s, const char t)
{
	int i=0;
    while(i<length)
    {
    	if(t_string[i] == s)
    	{
    		t_string[i] = t;
    	}
		i++;
    }
    return * this;
}

void String::PrintString()
{
    cout<<t_string<<endl;
}

int main(void)
{
    String str("helloworld");
    str.ReplaceChar('o', 'i');
    str.PrintString();
    return 0;
}
